package com.fsc.mapper;

import com.fsc.entity.domain.GroupMember;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fsc.entity.vo.GroupListContactVO;
import com.fsc.entity.vo.GroupWaitAddListVO;
import com.fsc.entity.vo.PersonContactListVO;
import com.fsc.entity.vo.PersonWaitAddListVO;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author 86183
* @description 针对表【group_member(群人员信息表)】的数据库操作Mapper
* @createDate 2024-06-14 11:17:08
* @Entity com.fsc.entity.domain.GroupMember
*/
public interface GroupMemberMapper extends BaseMapper<GroupMember> {
      @Select(" SELECT m.group_id,g.group_name,g.group_icon,g.number " +
              "FROM group_member m JOIN group_info  g " +
              " ON m.group_id=g.id " +
              "WHERE  m.member_id=#{id} AND m.status=1 ")
      List<GroupListContactVO> getYourGroupList(Integer id);

      @Select(" SELECT m.member_id ,m.nick_name,l.icon_url " +
              "FROM group_member m JOIN login_info l " +
              " ON m.member_id=l.id  " +
              "WHERE  m.group_id=#{groupId} AND m.status=1 ")
      List<PersonContactListVO> getGroupMemberList(Integer groupId);

      @Select(" SELECT a.group_id,a.group_name,a.member_id,l.username,l.icon_url,a.say_hello" +
              " FROM (SELECT m.group_id,g.group_name, m.member_id,m.say_hello" +
              " FROM group_member m JOIN group_info g on m.group_id=g.id" +
              " WHERE g.owner_id=#{id} AND m.status=0 order by m.join_time) a " +
              "JOIN login_info l on a.member_id=l.id"
             )
      List<GroupWaitAddListVO> getWaitAddList(Integer groupId);
}




